library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0      ✔ purrr   0.3.5 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.4.1 
## ✔ readr   2.1.3      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(readr)
abalone.cols = c("sex", "length", "diameter", "height", "whole.wt",
                 "shucked.wt", "viscera.wt", "shell.wt", "rings")

url <- 'http://archive.ics.uci.edu/ml/machine-learning-databases/abalone/abalone.data'
abalone <- read.table(url, sep=",", row.names=NULL, col.names=abalone.cols,
                      nrows=4177)
abalone%>% ggplot(aes(x=rings,y=whole.wt))+
      geom_density_2d_filled(alpha=0.8) +
  theme_minimal()+
  labs(title="Abalone data", subtitle="Filled contour")

 abalone%>% ggplot(aes(x= rings, y=whole.wt)) +
  stat_density_2d(aes(fill = ..density..), 
                  geom = "raster", 
                  contour = FALSE)+
  scale_fill_viridis_c(option = "magma")+
  theme_minimal()+
  labs(title="Abalone data", subtitle="2d KDE plot")

library(plot3D)
library(graph3d)
library(plotly)
library(MASS)

dist3d(x=abalone$length,y=abalone$rings,break.func = "Sturges",zlim=c(0,80))

plot_ly(abalone, x = ~length, y = ~ whole.wt, z = ~rings,size=1, alpha = 0.7, color  = ~sex)
## No trace type specified:
##   Based on info supplied, a 'scatter3d' trace seems appropriate.
##   Read more about this trace type -> https://plotly.com/r/reference/#scatter3d
## No scatter3d mode specifed:
##   Setting the mode to markers
##   Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
wine <- read.csv("https://raw.githubusercontent.com/amberkakkar01/Prediction-of-Wine-Quality/master/winequality-red.csv")
library(ggcorrplot)
fave_wine = wine %>% filter(quality<6) %>% dplyr::select(where(is.double))
corr <- round(cor(fave_wine),4)
ggcorrplot(corr, colors = c("red","white","green"))

ggcorrplot(corr,
           hc.order = TRUE, 
           type = "lower",
           colors = c("red", "white", "green"),
           method = "circle")

library(GGally)
ggpairs(wine[,c("pH", "chlorides", "citric.acid", "fixed.acidity", "volatile.acidity")], title="correlogram with ggpairs()", ggplot2::aes( alpha=0.009))

library(palmerpenguins)
data("penguins")
my_peng <- penguins %>% filter((bill_length_mm>40)&(bill_depth_mm>20)) %>% dplyr::select(where(is.double))
plot1 <- heatmap(as.matrix(my_peng) , Colv = NA, Rowv = NA, scale = "column",main="Heatmap with scaled variables")